﻿if exists (select * from sys.views where object_id = OBJECT_ID(N'tree_pivot'))
drop view tree_pivot;

if exists(select * from dbo.sysobjects where id = OBJECT_ID(N'tree_derive_concept') AND type = 'U')
drop table tree_derive_concept;

if exists(select * from dbo.sysobjects where id = OBJECT_ID(N'tree_derive') AND type = 'U')
drop table tree_derive;

if exists(select * from dbo.sysobjects where id = OBJECT_ID(N'tree_concept_ext') AND type = 'U')
drop table tree_concept_ext;

if exists(select * from dbo.sysobjects where id = OBJECT_ID(N'tree_concept') AND type = 'U')
drop table tree_concept;

if exists(select * from dbo.sysobjects where id = OBJECT_ID(N'tree_attr') AND type = 'U')
drop table tree_attr;

if exists(select * from dbo.sysobjects where id = OBJECT_ID(N'tree_use') AND type = 'U')
drop table tree_use

if exists(select * from dbo.sysobjects where id = OBJECT_ID(N'tree_link') AND type = 'U')
drop table tree_link;

if exists(select * from dbo.sysobjects where id = OBJECT_ID(N'tree_attr_type') AND type = 'U')
drop table tree_attr_type;

if exists(select * from dbo.sysobjects where id = OBJECT_ID(N'tree_category') AND type = 'U')
drop table tree_category;

if exists(select * from dbo.sysobjects where id = OBJECT_ID(N'tree') AND type = 'U')
drop table tree;

if exists(select * from dbo.sysobjects where id = OBJECT_ID(N'tree_gather') AND type = 'U')
drop table tree_gather;

--system tables
if exists(select * from dbo.sysobjects where id = OBJECT_ID(N'sys_setting') AND type = 'U')
drop table sys_setting;
